package com.example.rfidserver.ticket.subactivity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.rfidserver.R;
import com.example.rfidserver.dao.TicketDao;
import com.example.rfidserver.pojo.Ticket;
import com.example.rfidserver.status.FailActivity;
import com.example.rfidserver.status.SuccessActivity;

public class TicketAddActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ticket_add);
    }



    public void onClick(View view){
        //得到界面上的值
        TextView ticket_type_tv =(TextView)findViewById(R.id.ticket_type);
        TextView ticket_desp_tv = (TextView)findViewById(R.id.ticket_desp);
        String ticket_type = ticket_type_tv.getText().toString();
        String ticket_desp = ticket_desp_tv.getText().toString();
        TicketDao ticketDao = new TicketDao();
        int i = ticketDao.addOneTicket(ticket_type, ticket_desp);
        //执行成功，跳转到成功页面
        if(i!=0){
            Intent intent = new Intent(TicketAddActivity.this, SuccessActivity.class);
            startActivity(intent);
        }else{
            Intent intent = new Intent(TicketAddActivity.this, FailActivity.class);
            startActivity(intent);
        }
    }

}
